package com.example.demo.business.controller.v1;

import com.example.demo.business.bean.dto.VideoListDto;
import com.example.demo.business.bean.entity.HVideo;
import com.example.demo.business.bean.vo.VideoItemVo;
import com.example.demo.business.dao.HVideoDao;
import com.example.demo.business.service.VideoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.sql.Timestamp;
import java.time.LocalDateTime;
import java.util.*;

//获取电影
@RestController
@RequestMapping("v1")
public class VideoController {

    @Autowired
    private HVideoDao hVideoDao;

    @Autowired
    private VideoService videoService;
    //获取某分类下的视频
    @GetMapping("/category/video/list")
    public Object getVideoList(VideoListDto videoListDto,Pageable pageable){
        return videoService.getCategoryMovie(videoListDto, pageable);
    }

    //获取某分类下的视频
    @GetMapping("/video/search")
    public Object getVideoList(String searchKey,Pageable pageable){
        //名字搜索
        return videoService.movieSearch(searchKey, pageable);
    }

    //获取视频详情
    @GetMapping("/video/detail")
    public Object getVideoDetail(String videoId,String token){
        return videoService.getMovieDetail(videoId, token);
    }

    //获取视频推荐
    @GetMapping("/video/recommended")
    public Object getVideoRecommended(String videoId,String token,Pageable pageable){
        return videoService.getRecommendedMovie(videoId, token,pageable);
    }


    @GetMapping("/video/list")
    public Object getAllArrList(int[] ids){
        return videoService.getVideoList(ids);
    }

    //添加视频
    @GetMapping("/video/add/test")
    public Object addVideoList(){
        List<HVideo> avList = new ArrayList<>();
        hVideoDao.saveAll(avList);
        return "";
    }

    //用户下载视频
    @GetMapping("/video/down")
    public Object downVideo(String token,int videoId){
        return videoService.downVideo(token,videoId);
    }

    //用户顶或者踩视频 1顶2踩
    @GetMapping("/video/uporlow")
    public Object uporlow(String token,int videoId,int uporlow){
        return videoService.uporlow(token,videoId,uporlow);
    }

}
